<html lang="pt-br">
    <head>
        <meta http-equiv="content-type" content="text/html; charset=uft-8" />
        <?php 
			include_once ('header.php');
			include_once ('models/Marca.php');			
			include_once ('models/Veiculo.php');			
			
			$id = $_GET['id'];
						
			$m = new Marca;
			$v = new Veiculo;
			
			if($id > 0){
				$v->search($id);
			}	
			
		?>	
    </head>
    <body>
		<div class="conteudo">
			<div class="formulario">
				<form name="cadVeic" method="GET" action="<?php if($id > 0) echo 'veicCRUD.php?modo=edit'; else echo 'veicCRUD.php?modo=insert'; ?>">
					
					<div class="campo">
						<label for="cmbmarca">Marca</label><br>
						<select name="cmbmarca" id="cmbmarca" required="true">
							<option>[Selecione um motorista]</option>
							<?php 
								foreach($m->getList() as $m){
									if($id > 0){
										if($v->getMarca()->getID() == $m->getID())
											echo '<option value="'.$m->getID().'" selected>'.$m->getNome().'</option>';
										else	
											echo '<option value="'.$m->getID().'">'.$m->getNome().'</option>';
									}else
										echo '<option value="'.$m->getID().'">'.$m->getNome().'</option>';	
								}							
							?>							
						</select><br>
					</div>
					
					<div class="campo salto">
						<label for="txtmodelo">Modelo</label><br>
						<input type="text" value="<?php if ($id > 0) echo $v->getModelo(); ?>" id="txtmodelo" name="txtmodelo" required="true" size="49" /><br>						
					</div>
					
				  <div class="campo salto">				
						<label for="txtplaca">Placa</label><br>
						<input name="txtplaca" type="text" value="<?php  if ($id > 0)  echo $v->getPlaca(); ?>" id="txtplaca" maxlength="8" required="true" size="24"/>
						<label></label>
					</div>
					
					<div class="campo salto">
						<label for="txtano">Ano</label><br>
						<input type="text" value="<?php  if ($id > 0) echo $v->getAno(); ?>" id="txtano" name="txtano" maxlength="4" required="true" /><br>                                
					</div>
			
					<div class="campo salto">
						<label for="txtchassi">Chassi</label><br>
						<input type="text" value="<?php  if ($id > 0) echo $v->getChassi(); ?>" id="txtchassi" name="txtchassi" required="true" /><br>                                                
					</div>	
					
					<div class="ferramentas">
						<input class="botao save" type="submit" Value="Salvar">
						<input class="botao clear" type="reset" Value="Limpar">						
					</div>	
				</form>    
			</div>
		</div>   
    </body>
</html>